﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WHT_Auth {
    public partial class Info : Form {

        private string konami = "";

        public Info() {
            InitializeComponent();
            labelTechnical.Text = 
@"WHT-Auth tries to download information from https://stuwe.net.uni-tuebingen.de/netaccess/connstatus.html.
To login, a HTTPS GET is sent to the login page and then a POST
containing the username and password. The information is encrypted by SSL and not sent anywhere else.
The username is saved in plain text and the password encoded in Base64, so it is no problem to
read and decode it with access to the computer. Where exactly the information is saved depends on the
computer configuration.";
            linkAuthor.Focus();
                                   
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
            System.Diagnostics.Process.Start("http://www.gnu.org/copyleft/gpl.html");
        }

        private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
            System.Diagnostics.Process.Start("http://code.google.com/p/whtauth/");
        }

        private void Info_Load(object sender, EventArgs e) {

        }

        private void labelTechnical_Click(object sender, EventArgs e) {

        }

        private void linkAuthor_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
            System.Diagnostics.Process.Start("mailto:simon.stratmann@student.uni-tuebingen.de");
        }

        private void labelTechnical_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) {
            addKeyPress(e.KeyCode);
        }

        private void linkLabel1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) {
            addKeyPress(e.KeyCode);
        }

        private void addKeyPress(Keys pressedKey) {
            if (pressedKey == Keys.Down)
                konami += "d";
            if (pressedKey == Keys.Up)
                konami += "u";
            if (pressedKey == Keys.Left)
                konami += "l";
            if (pressedKey == Keys.Right)
                konami += "r";
            if (pressedKey == Keys.A)
                konami += "a";
            if (pressedKey == Keys.B)
                konami += "b";
            if (konami.Contains("uuddlrlrab")) {
                MessageBox.Show("CONTRA FTW");
                System.Diagnostics.Process.Start("http://www.pragmatick.de/contra.html");
            }
            
        }

        private void linkAuthor_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) {
            addKeyPress(e.KeyCode);
        }

        private void linkLabel2_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) {
            addKeyPress(e.KeyCode);
        }
    }
}
